package model.events;

import java.awt.Point;
import java.io.Serializable;

import model.path.CSPlayerPath;

import constants.GUIConstants;






/**
 * This class describes a LOS event : the LOS's event start time,
 * end time, the LOS target.
 * 
 * @author Urbanek Lucas (aka NaG)
 */
public class CSLOSEvent extends Point implements Serializable {
	private double startTime;
	private double endTime;
	private Point startPosition;
	
	private CSPlayerPath parent;
	
	/**
	 * The builder of the CSLOSEvent class.
	 * It is quite simple to understand.
	 * 
	 * @param x_
	 * @param y_
	 * @param start
	 * @param end
	 */
	public CSLOSEvent(int x_, int y_, int sx_, int sy_, double start, double end, CSPlayerPath parent_) {
		this.x = x_;
		this.y = y_;
		startPosition = new Point(sx_, sy_);
		startTime = start;
		endTime = end;
		parent = parent_;
	}
	
	public CSLOSEvent(Point p, Point startp, double start, double end, CSPlayerPath parent_) {
		this(p.x, p.y, startp.x, startp.y, start, end, parent_);
	}
	
	public boolean isSelectable(Point p) {
		if (this.distance(p)<GUIConstants.MIN_SELECTION_DISTANCE)
			return true;
		return false;
	}
	
	public Point getPosition() {
		return new Point(x,y);
	}
	
	public void setPosition(int x_, int y_) {
		this.x = x_;
		this.y = y_;
	}
	
	public void setPosition(Point pt) {
		this.setPosition(pt.x, pt.y);
	}
	
	public double getStartTime() {
		return startTime;
	}
	
	public void setStartTime(double start) {
		startTime = ((int)(start*100))/100d;
		setStartPosition(parent.getPositionAt(start));
	}
	
	public double getEndTime() {
		return endTime;
	}
	
	public void setEndTime(double end) {
		endTime = ((int)(end*100))/100d;
	}

	public Point getStartPosition() {
		return startPosition;
	}
	
	public void setStartPosition(Point newPosition) {
		startPosition = newPosition;
	}
}
